home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / appkit.712 < prev    next >
Text File  |  1992-02-06  |  3KB  |  81 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f1\fmodern Courier;\f2\fswiss Helvetica;}
  2. \paperw13040
  3. \paperh10800
  4. \margl120
  5. \margr120
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ul0\fs28 compositing\
  8. \
  9.  
  10. \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320 Q: There seems to be a problem in compositing under 2.0. Using  the CompositeLab in /NextDeveloper/Examples on a 2-bit screen, set the following parameters and use the SOVER operation:\
  11.  
  12. \f1\fs24\fc0 \
  13.  
  14. \f0\fs28\fi720 Source gray=1  opacity=0.3 (white mostly transparent source)\
  15. Dest   gray=0.8 opacity=1   (light gray opaque destination)\
  16.  
  17. \f2\fs24\fi0 \
  18.  
  19. \f0\fs28 You will see that the result is the same color as the destination. Thus the 30% coverage from the white source is having no effect at all!  Now change the source opacity down to 0; this causes no change in the result.  What's going on here?\
  20.  
  21. \f2\fs24 \
  22.  
  23. \f0\fs28 A: The 2.0 behavior is correct. Assume the case where the source is all white and is 33% opaque. Say the destination is 66% white and opaque. (This assures that we are using exact pixel values with no dithering.) The SOVER formula is:\
  24.  
  25. \f2\fs24 \
  26.  
  27. \f0\fs28\fi720 sourceColor * sourceOpacity + destColor * (1 - sourceOpacity)\
  28.  
  29. \f2\fs24\fi0 \
  30.  
  31. \f0\fs28 which for our case reduces to \
  32.  
  33. \f1\fs24 \
  34.  
  35. \f0\fs28\fi720 1 * 1/3 + 2/3 * 2/3 = 7/9\
  36.  
  37. \f2\fs24\fi0 \
  38.  
  39. \f0\fs28 which is rounded to 6/9, given that compositing only works on a per-pixel basis. Changing the opacity all the way down to 0 simply changes the resulting pixel to 6/9, thus no color change occurs.\
  40.  
  41. \f2\fs24 \
  42.  
  43. \f0\fs28 Now using the parameters in the question\
  44.  
  45. \f1\fs24 \
  46.  
  47. \f0\fs28\fi720 Source gray=1  opacity=0.3 (white mostly transparent source)\
  48. Dest   gray=0.8 opacity=1   (light gray opaque destination)\
  49.  
  50. \f2\fs24\fi0 \
  51.  
  52. \f0\fs28 We see that there are some source pixels with opacity of 0, and a few with opacity of 1/3. Source color is 1 in all cases. There are some dest pixels with gray of 1 and others with 2/3; opacity is 1 in both cases.\
  53.  
  54. \f2\fs24 \
  55.  
  56. \f0\fs28 Thus every resulting pixel is computed from one of four formulas:\
  57.  
  58. \f2\fs24 \
  59.  
  60. \pard\tx520\tx1060\tx2120\tx2260\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\f0\fs28\fi720\fc0 sourceColor * sourceOpacity + destColor * (1 - sourceOpacity)\
  61.  
  62. \pard\tx520\tx1060\tx2200\tx2660\tx4140\tx4640\tx5540\tx5740\tx7460\tx11840\fi1400\fc0 1    *      0    +    1    *    (1 -      0  )    = 1\
  63. 1    *    1/3    +    1    *    (1 -     1/3)    = 1\
  64. 1    *    0    +    2/3    *    (1 -      0   )    = 2/3 \
  65. 1    *    1/3    +    2/3    *    (1 -     1/3)    = 7/9\
  66.  
  67. \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\fc0 \
  68. Thus the result is equal to the dest color in all cases. \
  69. \
  70. If you wish to composite in a more accurate fashion, you can use 8-bit deep grayscale windows. However, this will use up a lot more memory and is probably not worth it.\
  71.  
  72. \f2\fs24 \
  73. \
  74.  
  75. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\fs28 QA712\
  76. \
  77. Not valid for 1.0\
  78. Valid for 2.0\
  79. \
  80.  
  81.